package top.jojoace.GlobalExceptionAdvice_And_AutoURI.Controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import top.jojoace.GlobalExceptionAdvice_And_AutoURI.Exception.http.NotFoundException;
import top.jojoace.GlobalExceptionAdvice_And_AutoURI.Service.UserServiceImpl;

@RestController
public class Contorller {
    @Autowired
    UserServiceImpl userService;

    /**
     * <h1>Exception</h1>
     * <h2>CheckedException 已检查异常。强制要求处理，如catch{}捕捉、方法throws抛出。</h2>
     * <h2>RuntimeException 运行时异常。不强制要求处理。</h2>
     * <p>CheckedException 一般用于能够处理的，如：找不到本地等文件、bug等。</p>
     * <p>RuntimeException 用于开发者无能为力的情况，如数据库查询用户输入的字符串等。</p>
     */
    @GetMapping("")
    public String get(){
        System.out.println("to throws Exception...");
        throw new RuntimeException("the RuntimeException...");
//        return userService.getStrUser();
    }



    @GetMapping("/2")
    public String get2(){
        throw new NotFoundException(10001);
    }
}
